import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Test2 {
    public int[] twoSum(int[] nums, int target) {
        if(nums==null||nums.length==0){
            return new int[]{-1,-1};
        }
        int[] res=new int[2];
        Map<Integer,Integer> hash=new HashMap<>();
        for (int i=0;i<nums.length;i++){
            int temp=target-nums[i];
            if(hash.containsKey(temp)){
                res[0]=hash.get(temp);
                res[1]=i;
                break;
            }
            hash.put(nums[i],i);
        }
        return res;
    }

    public static void main(String[] args) {
        Test2 test2=new Test2();
        int[] nums={2,7,11,15};
        test2.twoSum(nums,9);
        System.out.println(test2.twoSum(nums,9)[0]+" "+test2.twoSum(nums,9)[1]);
    }
}
